pp108 : Upload (XForms API)

Upload (XForms API)

 

The Upload control is used to upload files to server or to an application connector from any client location. It comprises an input field, a browse button, and a delete button. The default label is Attachment.

This control is derived from the Upload library. For details about the control's behavior and functionality, see Upload.

You can use the Message Map to create associations between this control and any required model. The mapping that you define between the control and the model is stored in a mapping object.

Properties, Events, and Methods of the Control

The properties, events, and methods associated with the Upload control define its behavior. You can set them either through the control's property sheet or programmatically using the APIs. For details, see Upload.

The following XForms-related properties are available for the control:

Table 1. List of Properties

Property

Description

ID

Sets the string that identifies the control on an XForm. If not specified, a unique ID is automatically generated.

Class Name

Sets or retrieves the class name applied on the control.

Visible

Sets a boolean value to specify whether the control will be displayed at run time or not. This property is useful when you handle the upload method through scripting.

Model

Sets the ID of the data model from which data (specified using the Reference property) is displayed in the control. If a model is not specified, it is inherited from the parent control's model.

Reference

Sets the location or XPath that contains the data (value) displayed in the control. The XPath refers to the child node or descendants of the immediate parent control's reference. The referred node is updated with Upload:FileName1 as value in the Update request of the model.

File Content Path

Mandatory. Sets the location or XPath of the uploaded file in the updated business object.

Request

Sets the request for the control. For this, you can use a method available in the Workspace or provide a SOAP request that includes the SOAP:Envelope tag. In case, a model is set for the control, the SOAP request is not considered.

Encode

Boolean that specifies whether the uploaded files are to be encoded or not.

  • true: Default. All the files to be uploaded are base64 encoded.
  • false: Files to be uploaded are not encoded. This case usually occurs when the user is uploading XML files.

Timeout

Integer that denotes the time (in milliseconds) that can be taken for the download method.

XML Content

Boolean that specifies whether the content of uploaded files is XML or not. This property is used only when the 'encode' is false.

  • true: Default. The file content is xml.
  • false: The file content is not xml.

Show Status

Boolean that denotes whether the upload status is to be indicated or not.

  • true: A progress bar appears when the file starts uploading. It shows the status of uploading, and closes automatically once the upload is over.
  • false: Default. Progress bar does not appear while uploading.

The following XForms-related events are available for the control:

Table 2. List of Events

Event

Description

onBeforeUpload

Activated before uploading a file.

onUpload

Activated when a file is uploaded.

The following XForms-related methods are available for the control:

Table 3. List of Methods

Method

Description

addListener(sEventName, fpFunction)

Registers a function to an event, such that the function gets called when the event is fired on the control.

getValue()

Returns the original value of the control, as available in the database.

removeListener(sEventName, fpFunction)

Unregisters a function from an event, such that the function stops getting called when the event is fired on the control.

setButtonLabel

Sets the button name of the upload control with the given string. The setButtonLabel(sLabel) accepts string as parameter.

getButtonLabel

Gets the button name of the upload control.

clearPath Clears the current file path from the upload control and sets the default message 'No file selected'.